package com.pm.comm.dao;

import java.util.List;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.mybatis.spring.annotation.MapperScan;

import com.pm.entity.CongressHall;

/**
 * 议事厅
 * @author Administrator
 *
 */
@MapperScan
public interface CongressHalldao {
	//不能写空的resultMap
	//@ResultMap("") 
	@Select("SELECT c.congress_hall_id,u.user_nickname,c.congress_hall_headline,c.congress_hall_content,c.congress_hall_time,p.picture_name,p.picture_imges FROM tb_congress_hall c INNER JOIN tb_picture p ON c.congress_hall_id = p.congress_hall_id INNER JOIN tb_user u ON u.user_id = c.user_id")
	List<CongressHall> findByAll();
	
	/**
	 * 删除
	 * @param congressHall
	 */
	@Delete("DELETE FROM tb_picture WHERE congress_hall_id=#{congress_hall_id};DELETE FROM tb_congress_hall WHERE congress_hall_id =#{congress_hall_id}")
	void deletByid(int congress_hall_id);
	
	/**
	 * 修改
	 * @param congressHall
	 */
	@Update("UPDATE tb_congress_hall SET congress_hall_headline=#{congress_hall_headline},congress_hall_content=#{congress_hall_content} WHERE congress_hall_id=#{congress_hall_id};UPDATE tb_picture SET picture_name=#{picture_name},picture_imges=#{picture_imges} WHERE congress_hall_id=#{congress_hall_id}")
	void updateid(CongressHall congressHall);
	
	/**
	 * 添加
	 * @param congressHall
	 * @return
	 */
	@Insert("INSERT INTO tb_congress_hall(congress_hall_headline,congress_hall_content,congress_hall_time,user_id) VALUES (#{congress_hall_headline},#{congress_hall_content},#{congress_hall_time},#{user_id});INSERT INTO tb_picture(picture_name,picture_imges,congress_hall_id) VALUES (#{picture_name},#{picture_imges},#{congress_hall_id})")
	int save(CongressHall congressHall);
	
}
